"""
通过开放数据接口（数据集）获取数据
XML - eXtensible Markup Language

<?xml version="1.0" encoding="utf-8"?>
<messages>
    <message language="en">
        <from>Hao</from>
        <to>Ting</to>
        <content>Hello, world!</content>
    </message>
    <message language="zh">
        <from>骆昊</from>
        <to>余婷</to>
        <content>晚饭你请</content>
    </message>
</messages>

JSON - JavaScript Object Notation
{
    messages: [
        {from: "Hao", to: "Ting", content: "Hello, world!"},
        {from: "骆昊", to: "余婷", content: "晚饭你请"}
    ]
}

YAML - Yet Another Markup Language
messages:
  message:
    from: Hao
    to: Ting
    content: Hello, world!
  message:
    from: 骆昊
    to: 余婷
    content: 晚饭你请
"""
import requests

key = 'e8c5524dd2a365f20908ced735f8e480'
for page in range(1, 11):
    resp = requests.get(
        f'http://api.tianapi.com/guonei/index?key={key}&num=20&page={page}'
    )
    news_list = resp.json()['newslist']
    for news in news_list:
        print(news['ctime'], news['title'], news['url'])
